import { RuleItem } from './rules'
import { UploadUserFile } from 'element-plus'
import { CSSProperties } from 'vue'

export type FormType =
  | 'autocomplete'
  | 'cascader'
  | 'checkbox'
  | 'checkbox-group'
  | 'color-picker'
  | 'date-picker'
  | 'input'
  | 'input-number'
  | 'radio'
  | 'radio-group'
  | 'rate'
  | 'select'
  | 'option'
  | 'slider'
  | 'switch'
  | 'time-picker'
  | 'time-select'
  | 'transfer'
  | 'upload'
  | 'editor'

export type FileListType = 'text' | 'picture' | 'picture-card'

export type T = unknown

export interface FormOptions {
  type: FormType
  value?: any
  prop?: string
  label?: string
  rules?: RuleItem[]
  attrs?: {
    placeholder?: string
    size?: string
    clearable?: boolean
    disabled?: boolean
    style?: CSSProperties
    [x: string]: T
  }
  children?: FormOptions[]

  /** 上传属性 */
  uploadAttrs?: {
    action: string
    headers?: Headers | Record<string, any>
    method?: string
    multiple?: boolean
    data?: Record<string, any>
    name?: string
    withCredentials?: boolean
    showFileList?: boolean
    drag?: boolean
    accept?: string
    fileList?: UploadUserFile[]
    listType?: FileListType
    autoUpload?: boolean
    disabled?: boolean
    limit?: number
  }
}
